﻿using System.Diagnostics;
using UnityEngine;
using Debug = UnityEngine.Debug;

namespace DL.Tools
{

    public class Debugger
    {
        private const string UNITY_EDITOR = "UNITY_EDITOR";
        private const string EDITOR_ONLY = "EDITOR_ONLY";

        /// <summary>
        /// 仅在 Editor 下打印
        /// </summary>
        [Conditional(UNITY_EDITOR)]
        [Conditional(EDITOR_ONLY)]
        public static void EO_Log(object msg, Color color = default)
        {
            if (color == default)
            {
                Debug.Log(msg);
                return;
            }

            Debug.Log(string.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGB(color), msg));
        }

        /// <summary>
        /// 仅在 Editor 下打印
        /// </summary>
        [Conditional(UNITY_EDITOR)]
        [Conditional(EDITOR_ONLY)]
        public static void EO_LogWarning(object msg, Color color = default)
        {
            if (color == default)
            {
                Debug.LogWarning(msg);
                return;
            }

            Debug.Log(string.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGB(color), msg));
        }

        /// <summary>
        /// 仅在 Editor 下打印
        /// </summary>
        [Conditional(UNITY_EDITOR)]
        [Conditional(EDITOR_ONLY)]
        public static void EO_LogError(object msg, Color color = default)
        {
            if (color == default)
            {
                Debug.LogError(msg);
                return;
            }

            Debug.Log(string.Format("<color=#{0}>{1}</color>", ColorUtility.ToHtmlStringRGB(color), msg));
        }

    }
}
